<?php

namespace App\Http\Controllers\OA;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Logic\AdminLogic;
use App\Http\Controllers\Logic\FinanceLogic;
use App\Http\Controllers\Logic\ProjectLogic;
use App\Http\Controllers\Logic\ProjectYsLogic;
use GuzzleHttp\Client;
use Illuminate\Http\Request;

/**
 * @desc 所有项目
 */

class ProjectMasterController extends Controller
{
    public function getWaitProject(Request $request)
    {
        try {
            
            $params = $this->mergeRequest($request);
            //dd($params);

            $params['page_size'] = 9999;

            $params['status'] = 0;

            $project_lx_count = (new ProjectLogic())->getProjectLx($params);//

            $lx = count($project_lx_count['data']);

            $params['type'] = 1;

            $project_ys_count = (new ProjectYsLogic())->getProjectYsList($params);//预算
            $ys = count($project_ys_count['data']);

            $params['type'] = 2;
            $project_js_count = (new ProjectYsLogic())->getProjectYsList($params);//
            $js = count($project_js_count['data']);

            unset($params['type']);

            $project_cw_count = (new FinanceLogic())->getList($params);
            $cw = count($project_cw_count['data']);

            $xm = $lx + $ys + $js;
            $params['state'] = $params['status'];
            $xz_data = (new AdminLogic())->baoXiaoList($params);
            $xz = count($xz_data['data']);
            $response = [
                'lx' => $lx,
                'ys' => $ys,
                'js' => $js,
                'cw' => $cw,
                'xz' => $xz,
                'xm' => $xm
            ];
            if ($request->has('need_return')) return $response;
            ret_json('ok', 'ok', $response);
        }catch (\Exception $e){
            ret_json('ok','ok',['lx'=>0,'ys'=>0,'js'=>0,'cw'=>0,'xz'=>0,'xm'=>0]);
        }
    }
}
